<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.3" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.3">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.3">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.3" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="categories: ZabbixZabbix + ElasticSearch + Kibana 安装配置介绍zabbix 4.2 新版本特性：  支持时序数据库（TimescaleDB） 支持Prometheus数据采集（Built-in） 高效高频监控 采集的数据验证和错误处理 使用JavaScript预处理数据">
<meta property="og:type" content="article">
<meta property="og:title" content="Zabbix + ElasticSearch + Kibana 实践">
<meta property="og:url" content="http://yoursite.com/2019/05/25/Zabbix+ElasticSearch+Kibana 实践/index.html">
<meta property="og:site_name" content="就这样">
<meta property="og:description" content="categories: ZabbixZabbix + ElasticSearch + Kibana 安装配置介绍zabbix 4.2 新版本特性：  支持时序数据库（TimescaleDB） 支持Prometheus数据采集（Built-in） 高效高频监控 采集的数据验证和错误处理 使用JavaScript预处理数据 从UI测试预处理规则 每秒处理百万级别指标 简单的低级别自动发现（low le">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143537.png">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143718.png">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143633.png">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143821.png">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143845.png">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143912.png">
<meta property="og:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143932.png">
<meta property="og:updated_time" content="2019-06-11T13:30:59.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Zabbix + ElasticSearch + Kibana 实践">
<meta name="twitter:description" content="categories: ZabbixZabbix + ElasticSearch + Kibana 安装配置介绍zabbix 4.2 新版本特性：  支持时序数据库（TimescaleDB） 支持Prometheus数据采集（Built-in） 高效高频监控 采集的数据验证和错误处理 使用JavaScript预处理数据 从UI测试预处理规则 每秒处理百万级别指标 简单的低级别自动发现（low le">
<meta name="twitter:image" content="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143537.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.3',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2019/05/25/Zabbix+ElasticSearch+Kibana 实践/"/>





  <title>Zabbix + ElasticSearch + Kibana 实践 | 就这样</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?cd728e866fd84c864ea2c8eb561ffbdf";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband">
      <a href="http://193.112.91.89:8080" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#FD6C6C; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    </div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">就这样</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">淋雨一直走</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/25/Zabbix+ElasticSearch+Kibana 实践/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="已经被时间上锁">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="就这样">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Zabbix + ElasticSearch + Kibana 实践</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-25T00:00:00+08:00">
                2019-05-25
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/zabbix/" itemprop="url" rel="index">
                    <span itemprop="name">zabbix</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2019/05/25/Zabbix+ElasticSearch+Kibana 实践/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2019/05/25/Zabbix+ElasticSearch+Kibana 实践/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2,877
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  15
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="categories-Zabbix"><a href="#categories-Zabbix" class="headerlink" title="categories: Zabbix"></a>categories: Zabbix</h2><h2 id="Zabbix-ElasticSearch-Kibana-安装配置"><a href="#Zabbix-ElasticSearch-Kibana-安装配置" class="headerlink" title="Zabbix + ElasticSearch + Kibana 安装配置"></a>Zabbix + ElasticSearch + Kibana 安装配置</h2><h3 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h3><p><strong>zabbix 4.2 新版本特性：<br></strong></p>
<ul>
<li>支持时序数据库（TimescaleDB）</li>
<li>支持Prometheus数据采集（Built-in）</li>
<li>高效高频监控</li>
<li>采集的数据验证和错误处理</li>
<li>使用JavaScript预处理数据</li>
<li>从UI测试预处理规则</li>
<li>每秒处理百万级别指标</li>
<li>简单的低级别自动发现（low level discovery）</li>
<li>简化的tag管理</li>
<li>更灵活的自动注册</li>
<li>控制自动发现的主机名</li>
<li>从Web UI测试媒介类型</li>
</ul>
<p><strong>elasticSearch 介绍</strong></p>
<p>Elasticsearch 是一个分布式、RESTful 风格的搜索和数据分析引擎，它的目的是通过简单的RESTful API来隐藏Lucene的复杂性，从而让全文搜索变得简单。</p>
<p><strong>Kibana 介绍</strong></p>
<p>Kibana是一个开源的分析和可视化平台，设计用于和Elasticsearch一起工作。可以用用Kibana来搜索，查看，并和存储在Elasticsearch索引中的数据进行交互。可以轻松地执行高级数据分析，并且以各种图标、表格和地图的形式可视化数据。</p>
<h5 id="zabbix-elasticsearch官网介绍"><a href="#zabbix-elasticsearch官网介绍" class="headerlink" title="zabbix+elasticsearch官网介绍"></a>zabbix+elasticsearch官网介绍</h5><blockquote>
<p>&emsp;zabbix支持Elasticsearch是实验性！配置步骤适用于以下Elasticsearch版本： 5.0.x - &gt; 6.1.x ,如果使用早期或更高版本的Elasticsearch，某些功能可能无法按预期工作。<br><br>&emsp;Zabbix最近开始支持通过使用Elasticsearch而不是数据库来存储历史数据。 现在，用户可以在兼容数据库和Elasticsearch之间选择历史数据的存储位置。</p>
</blockquote>
<h3 id="环境说明"><a href="#环境说明" class="headerlink" title="环境说明"></a>环境说明</h3><p><strong>本次测试系统环境</strong></p>
<ul>
<li>操作系统：CentOS 7.5</li>
<li>CPU：8核</li>
<li>内存：32G</li>
<li>硬盘：500G</li>
</ul>
<p><strong>本次相关应用版本</strong></p>
<ul>
<li>Zabbix: 4.2.1 LTS</li>
<li>Elasticsearch：6.1.4</li>
<li>Kibana：6.1.4</li>
<li>Httpd：2.4.35</li>
<li>PHP：7.2.11</li>
<li>Mysql：5.7.24</li>
</ul>
<h3 id="Apache-PHP-Mysql-Zabbix源码安装"><a href="#Apache-PHP-Mysql-Zabbix源码安装" class="headerlink" title="Apache + PHP + Mysql + Zabbix源码安装"></a>Apache + PHP + Mysql + Zabbix源码安装</h3><h4 id="apache安装"><a href="#apache安装" class="headerlink" title="apache安装"></a>apache安装</h4><p>省略</p>
<h4 id="PHP安装"><a href="#PHP安装" class="headerlink" title="PHP安装"></a>PHP安装</h4><p>省略</p>
<h4 id="mysql安装"><a href="#mysql安装" class="headerlink" title="mysql安装"></a>mysql安装</h4><p>省略</p>
<h4 id="zabbix安装"><a href="#zabbix安装" class="headerlink" title="zabbix安装"></a>zabbix安装</h4><h5 id="zabbix4-2编译安装"><a href="#zabbix4-2编译安装" class="headerlink" title="zabbix4.2编译安装"></a>zabbix4.2编译安装</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">创建文件夹</span><br><span class="line">mkdir -p /opr/aspire/product/package</span><br><span class="line">mkdir -p /opt/aspire/product/zabbix</span><br><span class="line"> </span><br><span class="line">新建zabbix用户</span><br><span class="line">useradd zabbix</span><br><span class="line">passwd zabbix</span><br><span class="line"> </span><br><span class="line">解压源码包</span><br><span class="line">tar zxvf zabbix-4.2.1.tar.gz -C /opt/aspire/product/package</span><br><span class="line"> </span><br><span class="line">目录授权</span><br><span class="line">chown -R zabbix.zabbix /opt/aspire/product/zabbix</span><br><span class="line"> </span><br><span class="line">编译安装</span><br><span class="line">cd /opt/aspire/product/zabbix</span><br><span class="line">./configure --prefix=/opt/aspire/product/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openIPMI --with-unixODBC</span><br><span class="line">make &amp;&amp; make install</span><br></pre></td></tr></table></figure>
<h5 id="创建数据库导入数据"><a href="#创建数据库导入数据" class="headerlink" title="创建数据库导入数据"></a>创建数据库导入数据</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">新建zabbix数据库</span><br><span class="line">&gt; create database zabbix character set utf-8 collate utf-8_bin</span><br><span class="line">&gt; grant all privileges on zabbix.* to zabbix_server@&quot;localhost&quot; identified by &quot;zabbix_password&quot;</span><br><span class="line">&gt; flush privileges</span><br><span class="line">&gt; exit</span><br><span class="line"> </span><br><span class="line">导入zabbix数据</span><br><span class="line">cd /opt/aspire/product/package/zabbix-4.2.1/database/mysql</span><br><span class="line">mysql -uzabbix -pzabbix_password &lt; schema.sql</span><br><span class="line">mysql -uzabbix -pzabbix_password zabbix &lt; images.sql</span><br><span class="line">mysql -uzabbix -pzabbix_password zabbix &lt; data.sql</span><br></pre></td></tr></table></figure>
<h5 id="修改php参数"><a href="#修改php参数" class="headerlink" title="修改php参数"></a>修改php参数</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">$ vi /etc/php.ini</span><br><span class="line"> </span><br><span class="line">date.timezone= Asia/Shanghai</span><br><span class="line">max_execution_time = 300</span><br><span class="line">post_max_size = 32M</span><br><span class="line">memory_limit = 128M</span><br><span class="line">mbstring.func_overload = 1</span><br><span class="line">max_input_time = 300</span><br></pre></td></tr></table></figure>
<h5 id="拷贝php文件到web目录"><a href="#拷贝php文件到web目录" class="headerlink" title="拷贝php文件到web目录"></a>拷贝php文件到web目录</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">拷贝php文件</span><br><span class="line">cp -r /opt/aspire/product/package/zabbix-4.2.1/frontends/php/ /opt/aspire/product/web/website/</span><br><span class="line"> </span><br><span class="line">目录授权</span><br><span class="line">chown -R zabbix.zabbix /opt/aspire/product/web/website/zabbix</span><br></pre></td></tr></table></figure>
<h5 id="修改zabbix-server配置文件"><a href="#修改zabbix-server配置文件" class="headerlink" title="修改zabbix_server配置文件"></a>修改zabbix_server配置文件</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">创建日志目录授权</span><br><span class="line">mkdir -p /opt/aspire/product/zabbix/logs</span><br><span class="line">chown zabbix.zabbix /opt/aspire/product/zabbix/logs</span><br><span class="line"> </span><br><span class="line">修改zabbix_server.conf</span><br><span class="line">$ vi /opt/aspire/product/zabbix/etc/zabbix_server.conf</span><br><span class="line"> </span><br><span class="line">LogFile=/opt/aspire/product/zabbix/logs/zabbix_server.log</span><br><span class="line">DBName=zabbix</span><br><span class="line">DBUser=zabbix</span><br><span class="line">DBPassword=zabbix2018</span><br><span class="line">Timeout=4</span><br><span class="line">LogSlowQueries=3000</span><br></pre></td></tr></table></figure>
<h5 id="zabbix服务自启动"><a href="#zabbix服务自启动" class="headerlink" title="zabbix服务自启动"></a>zabbix服务自启动</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">拷贝启动脚本</span><br><span class="line">cd /opt/aspire/product/package/zabbix-4.2.1</span><br><span class="line">cp misc/init.d/fedora/core/zabbix_server /etc/init.d/</span><br><span class="line"> </span><br><span class="line">编辑启动文件</span><br><span class="line">vi /etc/init.d/zabbix_server</span><br><span class="line"> </span><br><span class="line">BASEDIR=/opt/aspire/product/zabbix</span><br><span class="line">CONFFILE=$BASEDIR/etc/zabbix_server.conf</span><br><span class="line">action $&quot;Starting $BINARY_NAME: &quot; $FULLPATH -c $CONFFILE</span><br><span class="line"> </span><br><span class="line">设置开机自启动</span><br><span class="line">chkconfig --add zabbix_server</span><br><span class="line">chkconfig zabbix_server on</span><br></pre></td></tr></table></figure>
<h5 id="启动zabbix-server"><a href="#启动zabbix-server" class="headerlink" title="启动zabbix_server"></a>启动zabbix_server</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/etc/init.d/zabbix_server restart</span><br></pre></td></tr></table></figure>
<h3 id="ElasticSearch-安装配置"><a href="#ElasticSearch-安装配置" class="headerlink" title="ElasticSearch 安装配置"></a>ElasticSearch 安装配置</h3><h4 id="jdk-安装配置配置"><a href="#jdk-安装配置配置" class="headerlink" title="jdk 安装配置配置"></a>jdk 安装配置配置</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">创建jdk文件夹</span><br><span class="line">mkdir -p /opt/aspire/product/jdk</span><br><span class="line"> </span><br><span class="line">解压jdk压缩包</span><br><span class="line">tar zxvf jdk-8u181-linux-x64.tar.gz -C /opt/aspire/product/jdk</span><br><span class="line"> </span><br><span class="line">编辑profile文件，添加jdk环境变量</span><br><span class="line">$ vi /etc/profile</span><br><span class="line"> </span><br><span class="line">JAVA_HOME=//app/jdk/jdk1.8.0_181</span><br><span class="line">CLASSPATH=$JAVA_HOME/lib/</span><br><span class="line">PATH=$PATH:$JAVA_HOME/bin</span><br><span class="line">export PATH JAVA_HOME CLASSPATH</span><br><span class="line"> </span><br><span class="line">验证java环境，有输出正常</span><br><span class="line">$ java version</span><br></pre></td></tr></table></figure>
<h4 id="系统参数调整"><a href="#系统参数调整" class="headerlink" title="系统参数调整"></a>系统参数调整</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">编辑limit.conf配置文件</span><br><span class="line">$ vi /etc/security/limits.conf</span><br><span class="line">*          soft    nofile  65536</span><br><span class="line">*          hard    nofile  131072</span><br><span class="line">zabbix     soft    memlock unlimited</span><br><span class="line">zabbix     hard    memlock unlimited</span><br><span class="line">zabbix     hard    nproc   4096</span><br><span class="line">zabbix     soft    nproc   4096</span><br><span class="line"> </span><br><span class="line">内核参数优化</span><br><span class="line">$ vim /etc/sysctl.conf</span><br><span class="line">vm.max_map_count=262144</span><br><span class="line">vm.swappiness=1</span><br><span class="line"> </span><br><span class="line">$ sysctl -p</span><br></pre></td></tr></table></figure>
<h4 id="elasticsearch-6-1-4-安装配置"><a href="#elasticsearch-6-1-4-安装配置" class="headerlink" title="elasticsearch 6.1.4 安装配置"></a>elasticsearch 6.1.4 安装配置</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line">1.elesticsearch 6.1.4 下载</span><br><span class="line">省略</span><br><span class="line"> </span><br><span class="line">2.解压elasticsearch</span><br><span class="line">tar zxvf elesticsearch-6.1.4.tar.gz -C /opt/aspire/product/</span><br><span class="line">cd /opt/aspire/product</span><br><span class="line">mv elesticsearch-6.1.4 eleasticsearch6</span><br><span class="line"> </span><br><span class="line">3.创建data和logs文件夹</span><br><span class="line">mkdir -p eleasticsearch6/data</span><br><span class="line">mkdir -p eleasticsearch6/logs</span><br><span class="line"> </span><br><span class="line">4.授权目录权限</span><br><span class="line">chown -R zabbix.zabbix /opt/aspire/product/eleasticsearch6</span><br><span class="line"> </span><br><span class="line">5.修改配置文件</span><br><span class="line">$ vi /opt/aspire/product/zabbix/elasticsearch6/config/elasticsearch.yml</span><br><span class="line"> </span><br><span class="line">#集群名称</span><br><span class="line">cluster.name: zabbix_elasticsearch</span><br><span class="line">#node节点的名称</span><br><span class="line">node.name: node-1 </span><br><span class="line"># 服务监听的ip地址</span><br><span class="line">network.host: 10.12.70.42</span><br><span class="line"># 是否可以成为主节点</span><br><span class="line">node.master: true</span><br><span class="line"># 该节点是否可以存储数据</span><br><span class="line">node.data: true</span><br><span class="line"># 节点属性</span><br><span class="line">node.attr.rack: r1</span><br><span class="line"># 设置索引数据的存储路径，多存储路径的话用逗号隔开</span><br><span class="line">path.data: /opt/aspire/product/zabbix/elasticsearch6/data</span><br><span class="line"># 日志存放路径</span><br><span class="line">path.logs: /opt/aspire/product/zabbix/elasticsearch6/logs</span><br><span class="line"># 锁定进程使用 的物理内存地址，避免使用swap</span><br><span class="line">bootstrap.memory_lock: true</span><br><span class="line"># 对外发布的ip</span><br><span class="line">network.host: 0.0.0.0</span><br><span class="line"># 设置对外服务的http端口，默认为9200</span><br><span class="line">http.port: 9200</span><br><span class="line"># 节点交互使用的tcp端口</span><br><span class="line">transport.tcp.port: 9300</span><br><span class="line"># 设置集群中master节点的初始列表，可以通过这些节点来自动发现新加入集群的节点。</span><br><span class="line">discovery.zen.ping.unicast.hosts: [&quot;10.12.70.42&quot;]</span><br><span class="line"># 如果启用了 HTTP 端口，那么此属性会指定是否允许跨源 REST 请求</span><br><span class="line">http.cors.enabled: true</span><br><span class="line"># 如果 http.cors.enabled 的值为 true，那么该属性会指定允许 REST 请求来自何处。</span><br><span class="line">http.cors.allow-origin: &quot;*&quot;</span><br><span class="line"> </span><br><span class="line">6.以zabbix用户启动（不能使用root用户启动）</span><br><span class="line">su - zabbix</span><br><span class="line">cd /opt/aspire/product/elasticsearch6/bin</span><br><span class="line">./elasticsearch -d</span><br><span class="line"> </span><br><span class="line">7.验证安装情况,有如下输出则正常</span><br><span class="line">$ curl http://10.12.70.42:9200</span><br><span class="line">&#123;</span><br><span class="line">  &quot;name&quot; : &quot;node-1&quot;,</span><br><span class="line">  &quot;cluster_name&quot; : &quot;zabbix_elasticsearch&quot;,</span><br><span class="line">  &quot;cluster_uuid&quot; : &quot;Aj_2YjcXRzSgaJLF0BQWjw&quot;,</span><br><span class="line">  &quot;version&quot; : &#123;</span><br><span class="line">    &quot;number&quot; : &quot;6.1.4&quot;,</span><br><span class="line">    &quot;build_hash&quot; : &quot;d838f2d&quot;,</span><br><span class="line">    &quot;build_date&quot; : &quot;2018-03-14T08:28:22.470Z&quot;,</span><br><span class="line">    &quot;build_snapshot&quot; : false,</span><br><span class="line">    &quot;lucene_version&quot; : &quot;7.1.0&quot;,</span><br><span class="line">    &quot;minimum_wire_compatibility_version&quot; : &quot;5.6.0&quot;,</span><br><span class="line">    &quot;minimum_index_compatibility_version&quot; : &quot;5.0.0&quot;</span><br><span class="line">  &#125;,</span><br><span class="line">  &quot;tagline&quot; : &quot;You Know, for Search&quot;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="elasticsearch-head插件安装"><a href="#elasticsearch-head插件安装" class="headerlink" title="elasticsearch-head插件安装"></a>elasticsearch-head插件安装</h4><p>可通过chrome浏览器插件和npm管理器两种方式安装</p>
<ul>
<li>在chrome应用商店安装elasticsearch-head插件即可<br></li>
<li>通过npm管理器安装</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">1.npm安装head插件</span><br><span class="line"> </span><br><span class="line">#创建相关目录</span><br><span class="line">mkdir /opt/aspire/product/elasticsearch-head</span><br><span class="line">cd /opt/aspire/product/elasticsearch-head</span><br><span class="line"> </span><br><span class="line">#安装相关依赖</span><br><span class="line">yum -y install nodejs npm</span><br><span class="line">git clone https://github.com/mobz/elasticsearch-head.git</span><br><span class="line">npm install grunt-cli</span><br><span class="line">npm install</span><br><span class="line"> </span><br><span class="line">2.修改配置文件</span><br><span class="line"> </span><br><span class="line"># 修改Gruntfile.js文件，修改监控地址，增加hostname属性</span><br><span class="line">$ vi Gruntfile.js</span><br><span class="line"> </span><br><span class="line">connect: &#123;</span><br><span class="line">                        server: &#123;</span><br><span class="line">                                options: &#123;</span><br><span class="line">                                        port: 9201,</span><br><span class="line">                                        base: &apos;.&apos;,</span><br><span class="line">                                        keepalive: true</span><br><span class="line">                                &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                &#125;</span><br><span class="line"> </span><br><span class="line"># 修改head/_site/app.js，修改head连接es的地址</span><br><span class="line">$ vi app.js</span><br><span class="line">this.base_uri = this.config.base_uri || this.prefs.get(&quot;app-base_uri&quot;) || &quot;http://localhost:9200&quot;;</span><br><span class="line"> </span><br><span class="line">3.后台启动</span><br><span class="line">cd /opt/aspire/product/elasticsearch-head/node_modules/grunt/bin</span><br><span class="line">nohup ./grunt server &amp; exit</span><br><span class="line">启动成功后，可在浏览器访问插件与ES进行交互</span><br><span class="line">http://10.12.70.42:9201/</span><br></pre></td></tr></table></figure>
<p>界面展示如下<br><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143537.png" alt=""></p>
<h3 id="Kibana-安装配置"><a href="#Kibana-安装配置" class="headerlink" title="Kibana 安装配置"></a>Kibana 安装配置</h3><h4 id="Kibana下载"><a href="#Kibana下载" class="headerlink" title="Kibana下载"></a>Kibana下载</h4><p>省略</p>
<h4 id="Kibana-安装配置-1"><a href="#Kibana-安装配置-1" class="headerlink" title="Kibana 安装配置"></a>Kibana 安装配置</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">1.创建kibana文件目录</span><br><span class="line">cd /opt/aspire/product</span><br><span class="line">mkdir kibana6</span><br><span class="line"> </span><br><span class="line">2.解压并授权</span><br><span class="line">tar zxvf kibana-6.1.4-linux-x86_64.tar.gz -C kibana6/</span><br><span class="line">chown -R zabbix.zabbix kibana6/</span><br><span class="line"> </span><br><span class="line">3.修改配置文件</span><br><span class="line">$ vi kibana.yml</span><br><span class="line"># </span><br><span class="line"># kibana服务对外端口</span><br><span class="line">server.port: 5601</span><br><span class="line"># 本机ip</span><br><span class="line">server.host: &quot;10.12.70.42&quot;</span><br><span class="line"># elasticsearch地址</span><br><span class="line">elasticsearch.url: &quot;http://10.12.70.42:9200&quot;</span><br></pre></td></tr></table></figure>
<p>web界面如下：<br><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143718.png" alt=""></p>
<h3 id="Zabbix-同-ElasticSearch对接"><a href="#Zabbix-同-ElasticSearch对接" class="headerlink" title="Zabbix 同 ElasticSearch对接"></a>Zabbix 同 ElasticSearch对接</h3><p>Elasticsearch支持以下几种监控项类型：uint,dbl,str,log,text<br>支持的监控项类型通zabbix数据库说明如下：</p>
<table>
<thead>
<tr>
<th style="text-align:center">监控项值类型</th>
<th style="text-align:center">数据库表</th>
<th style="text-align:center">Elasticsearch类型</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">Numeric(unsigned)</td>
<td style="text-align:center">history_uint</td>
<td style="text-align:center">uint</td>
</tr>
<tr>
<td style="text-align:center">Numeric(float)</td>
<td style="text-align:center">history</td>
<td style="text-align:center">dbl</td>
</tr>
<tr>
<td style="text-align:center">Character</td>
<td style="text-align:center">history_str</td>
<td style="text-align:center">str</td>
</tr>
<tr>
<td style="text-align:center">Log</td>
<td style="text-align:center">history_log</td>
<td style="text-align:center">log</td>
</tr>
<tr>
<td style="text-align:center">Text</td>
<td style="text-align:center">history_text</td>
<td style="text-align:center">text</td>
</tr>
</tbody>
</table>
<h4 id="zabbix-server配置"><a href="#zabbix-server配置" class="headerlink" title="zabbix_server配置"></a>zabbix_server配置</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">1：修改zabbix_server.conf配置文件</span><br><span class="line">$ vi /opt/aspire/product/zabbix/etc/zabbix_server.conf</span><br><span class="line"> </span><br><span class="line">HistoryStorageURL=http://10.12.70.42:9200</span><br><span class="line">HistoryStorageTypes=str,text,log,dbl,uint</span><br><span class="line"> </span><br><span class="line">2：修改zabbix.conf.php文件</span><br><span class="line">$ vi /opt/aspire/product/web/website/zabbix/conf/zabbix.conf.php</span><br><span class="line"> </span><br><span class="line">(1):多台elasticsearch集群可按照如下方式配置</span><br><span class="line">$HISTORY[&apos;url&apos;]   = [</span><br><span class="line">    &apos;uint&apos; =&gt; &apos;http://l.1.1.1:9200&apos;,</span><br><span class="line">    &apos;text&apos; =&gt; &apos;http://2.2.2.2:9200&apos;</span><br><span class="line">];</span><br><span class="line">$HISTORY[&apos;types&apos;] = [&apos;uint&apos;, &apos;text&apos;];</span><br><span class="line"> </span><br><span class="line">(2):单台elsaticsearch汇总按照如下配置</span><br><span class="line">global $HISTORY;$DB;</span><br><span class="line">$HISTORY[&apos;url&apos;]   = &apos;http://10.12.70.42:9203&apos;;</span><br><span class="line">// Value types stored in Elasticsearch.</span><br><span class="line">$HISTORY[&apos;types&apos;] = [&apos;str&apos;, &apos;text&apos;, &apos;log&apos;,&apos;dbl&apos;,&apos;uint&apos;];</span><br></pre></td></tr></table></figure>
<h4 id="添加Elasticsearch-mapping"><a href="#添加Elasticsearch-mapping" class="headerlink" title="添加Elasticsearch mapping"></a>添加Elasticsearch mapping</h4><p>可在elasticsearch-head界面，kibana Dev tools界面操作，也可以使用curl命令操作</p>
<p>Kibana Dev tools界面：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">PUT /uint &#123;json数据&#125;</span><br><span class="line">PUT /dbl &#123;json数据&#125;</span><br><span class="line">PUT /str &#123;json数据&#125;</span><br><span class="line">PUT /log &#123;json数据&#125;</span><br><span class="line">PUT /text &#123;json数据&#125;</span><br></pre></td></tr></table></figure>
<p>Curl 命令操作：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl -H &quot;Content-Type:application/json&quot; -XPUT http://10.12.70.42:9203/uint -d  &apos; &#123;json数据&#125; &apos;</span><br><span class="line">curl -H &quot;Content-Type:application/json&quot; -XPUT http://10.12.70.42:9203/dbl -d  &apos; &#123;json数据&#125; &apos;</span><br><span class="line">curl -H &quot;Content-Type:application/json&quot; -XPUT http://10.12.70.42:9203/str -d  &apos; &#123;json数据&#125; &apos;</span><br><span class="line">curl -H &quot;Content-Type:application/json&quot; -XPUT http://10.12.70.42:9203/text -d  &apos; &#123;json数据&#125; &apos;</span><br><span class="line">curl -H &quot;Content-Type:application/json&quot; -XPUT http://10.12.70.42:9203/log -d  &apos; &#123;json数据&#125; &apos;</span><br></pre></td></tr></table></figure></p>
<p><strong>json数据格式如下</strong></p>
<h6 id="1-添加uint-mapping"><a href="#1-添加uint-mapping" class="headerlink" title="1.添加uint_mapping"></a>1.添加uint_mapping</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">   &quot;settings&quot; : &#123;</span><br><span class="line">      &quot;index&quot; : &#123;</span><br><span class="line">         &quot;number_of_replicas&quot; : 1,</span><br><span class="line">         &quot;number_of_shards&quot; : 5</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;,</span><br><span class="line">   &quot;mappings&quot; : &#123;</span><br><span class="line">      &quot;values&quot; : &#123;</span><br><span class="line">         &quot;properties&quot; : &#123;</span><br><span class="line">            &quot;itemid&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;long&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;clock&quot; : &#123;</span><br><span class="line">               &quot;format&quot; : &quot;epoch_second&quot;,</span><br><span class="line">               &quot;type&quot; : &quot;date&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;value&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;long&quot;</span><br><span class="line">            &#125;</span><br><span class="line">         &#125;</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h6 id="2-添加dbl-mapping"><a href="#2-添加dbl-mapping" class="headerlink" title="2.添加dbl_mapping"></a>2.添加dbl_mapping</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">&#123; </span><br><span class="line">   &quot;settings&quot; : &#123;</span><br><span class="line">      &quot;index&quot; : &#123;</span><br><span class="line">         &quot;number_of_replicas&quot; : 1,</span><br><span class="line">         &quot;number_of_shards&quot; : 5</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;,</span><br><span class="line">   &quot;mappings&quot; : &#123;</span><br><span class="line">      &quot;values&quot; : &#123;</span><br><span class="line">         &quot;properties&quot; : &#123;</span><br><span class="line">            &quot;itemid&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;long&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;clock&quot; : &#123;</span><br><span class="line">               &quot;format&quot; : &quot;epoch_second&quot;,</span><br><span class="line">               &quot;type&quot; : &quot;date&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;value&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;double&quot;</span><br><span class="line">            &#125;</span><br><span class="line">         &#125;</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h6 id="3-添加str-mapping"><a href="#3-添加str-mapping" class="headerlink" title="3.添加str_mapping"></a>3.添加str_mapping</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">&#123; </span><br><span class="line">   &quot;settings&quot; : &#123;</span><br><span class="line">      &quot;index&quot; : &#123;</span><br><span class="line">         &quot;number_of_replicas&quot; : 1,</span><br><span class="line">         &quot;number_of_shards&quot; : 5</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;,</span><br><span class="line">   &quot;mappings&quot; : &#123;</span><br><span class="line">      &quot;values&quot; : &#123;</span><br><span class="line">         &quot;properties&quot; : &#123;</span><br><span class="line">            &quot;itemid&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;long&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;clock&quot; : &#123;</span><br><span class="line">               &quot;format&quot; : &quot;epoch_second&quot;,</span><br><span class="line">               &quot;type&quot; : &quot;date&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;value&quot; : &#123;</span><br><span class="line">               &quot;fields&quot; : &#123;</span><br><span class="line">                  &quot;analyzed&quot; : &#123;</span><br><span class="line">                     &quot;index&quot; : true,</span><br><span class="line">                     &quot;type&quot; : &quot;text&quot;,</span><br><span class="line">                     &quot;analyzer&quot; : &quot;standard&quot;</span><br><span class="line">                  &#125;</span><br><span class="line">               &#125;,</span><br><span class="line">               &quot;index&quot; : false,</span><br><span class="line">               &quot;type&quot; : &quot;text&quot;</span><br><span class="line">            &#125;</span><br><span class="line">         &#125;</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h6 id="4-添加text-mapping"><a href="#4-添加text-mapping" class="headerlink" title="4.添加text_mapping"></a>4.添加text_mapping</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">   &quot;settings&quot; : &#123;</span><br><span class="line">      &quot;index&quot; : &#123;</span><br><span class="line">         &quot;number_of_replicas&quot; : 1,</span><br><span class="line">         &quot;number_of_shards&quot; : 5</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;,</span><br><span class="line">   &quot;mappings&quot; : &#123;</span><br><span class="line">      &quot;values&quot; : &#123;</span><br><span class="line">         &quot;properties&quot; : &#123;</span><br><span class="line">            &quot;itemid&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;long&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;clock&quot; : &#123;</span><br><span class="line">               &quot;format&quot; : &quot;epoch_second&quot;,</span><br><span class="line">               &quot;type&quot; : &quot;date&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;value&quot; : &#123;</span><br><span class="line">               &quot;fields&quot; : &#123;</span><br><span class="line">                  &quot;analyzed&quot; : &#123;</span><br><span class="line">                     &quot;index&quot; : true,</span><br><span class="line">                     &quot;type&quot; : &quot;text&quot;,</span><br><span class="line">                     &quot;analyzer&quot; : &quot;standard&quot;</span><br><span class="line">                  &#125;</span><br><span class="line">               &#125;,</span><br><span class="line">               &quot;index&quot; : false,</span><br><span class="line">               &quot;type&quot; : &quot;text&quot;</span><br><span class="line">            &#125;</span><br><span class="line">         &#125;</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h6 id="5-添加log-mapping"><a href="#5-添加log-mapping" class="headerlink" title="5.添加log_mapping"></a>5.添加log_mapping</h6><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">   &quot;settings&quot; : &#123;</span><br><span class="line">      &quot;index&quot; : &#123;</span><br><span class="line">         &quot;number_of_replicas&quot; : 1,</span><br><span class="line">         &quot;number_of_shards&quot; : 5</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;,</span><br><span class="line">   &quot;mappings&quot; : &#123;</span><br><span class="line">      &quot;values&quot; : &#123;</span><br><span class="line">         &quot;properties&quot; : &#123;</span><br><span class="line">            &quot;itemid&quot; : &#123;</span><br><span class="line">               &quot;type&quot; : &quot;long&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;clock&quot; : &#123;</span><br><span class="line">               &quot;format&quot; : &quot;epoch_second&quot;,</span><br><span class="line">               &quot;type&quot; : &quot;date&quot;</span><br><span class="line">            &#125;,</span><br><span class="line">            &quot;value&quot; : &#123;</span><br><span class="line">               &quot;fields&quot; : &#123;</span><br><span class="line">                  &quot;analyzed&quot; : &#123;</span><br><span class="line">                     &quot;index&quot; : true,</span><br><span class="line">                     &quot;type&quot; : &quot;text&quot;,</span><br><span class="line">                     &quot;analyzer&quot; : &quot;standard&quot;</span><br><span class="line">                  &#125;</span><br><span class="line">               &#125;,</span><br><span class="line">               &quot;index&quot; : false,</span><br><span class="line">               &quot;type&quot; : &quot;text&quot;</span><br><span class="line">            &#125;</span><br><span class="line">         &#125;</span><br><span class="line">      &#125;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>添加后elasticsearch-head界面如下：<br><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143633.png" alt=""></p>
<h4 id="Kibana关联elasticsearch"><a href="#Kibana关联elasticsearch" class="headerlink" title="Kibana关联elasticsearch"></a>Kibana关联elasticsearch</h4><h5 id="创建索引正则"><a href="#创建索引正则" class="headerlink" title="创建索引正则"></a>创建索引正则</h5><p><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143821.png" alt=""></p>
<p><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143845.png" alt=""></p>
<p>依次创建dbl,str,uint的index pattern即可</p>
<h5 id="kibana过滤数据"><a href="#kibana过滤数据" class="headerlink" title="kibana过滤数据"></a>kibana过滤数据</h5><p><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143912.png" alt=""></p>
<p>假设查询str*下的数据，根据itemid value筛选数据如下<br><img src="https://waney316-blog.oss-cn-shenzhen.aliyuncs.com/img/20190611143932.png" alt=""></p>
<hr>
<h4 id="附录：X-pack安装"><a href="#附录：X-pack安装" class="headerlink" title="附录：X-pack安装"></a>附录：X-pack安装</h4><p>在 Elasticsearch 中，配置认证是通过 X-Pack 插件实现的，kibana 版本高于6.3.2的已经自动集成了x-pack插件，低于该版本需要自行安装x-pack</p>
<h5 id="x-pack-安装"><a href="#x-pack-安装" class="headerlink" title="x-pack 安装"></a>x-pack 安装</h5><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">下载x-pack</span><br><span class="line">wget https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-6.2.2.zip</span><br><span class="line"> </span><br><span class="line">进入kibana/bin目录，安装</span><br><span class="line">kibana-plugin install x-pack-6.2.2.zip</span><br><span class="line"> </span><br><span class="line">修改kibana配置文件</span><br><span class="line">$ vi kibana.yml</span><br><span class="line"> </span><br><span class="line">elasticsearch.username: &quot;kibana&quot;</span><br><span class="line">elasticsearch.password: &quot;CeoxAZHhQ17Hm9tyux33&quot;</span><br><span class="line">server.name: &quot;zdh-7&quot;</span><br><span class="line">server.host: &quot;10.43.159.7&quot;</span><br><span class="line">elasticsearch.url: &quot;http://10.43.159.7:9200&quot;</span><br><span class="line">xpack.monitoring.enabled: true</span><br><span class="line">xpack.security.enabled: true</span><br><span class="line">xpack.ml.enabled: true</span><br><span class="line">xpack.watcher.enabled: true</span><br><span class="line">xpack.graph.enabled: true</span><br><span class="line"> </span><br><span class="line">重启kibana进程</span><br><span class="line">$ ps -ef |grep node/bin/node |grep -v grep</span><br><span class="line">$ kill 9 pid</span><br><span class="line">$ /bin/kibana &amp;</span><br></pre></td></tr></table></figure>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/wechatpay.jpg" alt="已经被时间上锁 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/alipay.jpg" alt="已经被时间上锁 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/05/20/vsftp配置及虚拟用户创建.md/" rel="next" title="VSftp配置及虚拟用户创建">
                <i class="fa fa-chevron-left"></i> VSftp配置及虚拟用户创建
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/06/03/Zabbix3.4升级4.2线上操作方案/" rel="prev" title="Zabbix3.4升级4.2线上操作方案">
                Zabbix3.4升级4.2线上操作方案 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.png"
                alt="已经被时间上锁" />
            
              <p class="site-author-name" itemprop="name">已经被时间上锁</p>
              <p class="site-description motion-element" itemprop="description">只剩挥散不去的难过</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">9</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">9</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          <div class="links-of-author motion-element">
            
              
                <span class="links-of-author-item">
                  <a href="http://i2.bvimg.com/624619/509703ad18473233.jpg" target="_blank" title="Wechat">
                    
                      <i class="fa fa-fw fa-wechat"></i>Wechat</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://github.com/waney316" target="_blank" title="GitHub">
                    
                      <i class="fa fa-fw fa-github"></i>GitHub</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:waney316@foxmail.com" target="_blank" title="E-Mail">
                    
                      <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://weibo.com/3020883227" target="_blank" title="Weibo">
                    
                      <i class="fa fa-fw fa-weibo"></i>Weibo</a>
                </span>
              
            
          </div>

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                友情链接
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://bbs.csdn.net/home" title="CSDN" target="_blank">CSDN</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://man.linuxde.net/" title="Linux命令" target="_blank">Linux命令</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.runoob.com/" title="菜鸟教程" target="_blank">菜鸟教程</a>
                  </li>
                
              </ul>
            </div>
          
          <br>

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#categories-Zabbix"><span class="nav-number">1.</span> <span class="nav-text">categories: Zabbix</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Zabbix-ElasticSearch-Kibana-安装配置"><span class="nav-number">2.</span> <span class="nav-text">Zabbix + ElasticSearch + Kibana 安装配置</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#介绍"><span class="nav-number">2.1.</span> <span class="nav-text">介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#zabbix-elasticsearch官网介绍"><span class="nav-number">2.1.0.1.</span> <span class="nav-text">zabbix+elasticsearch官网介绍</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#环境说明"><span class="nav-number">2.2.</span> <span class="nav-text">环境说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Apache-PHP-Mysql-Zabbix源码安装"><span class="nav-number">2.3.</span> <span class="nav-text">Apache + PHP + Mysql + Zabbix源码安装</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#apache安装"><span class="nav-number">2.3.1.</span> <span class="nav-text">apache安装</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#PHP安装"><span class="nav-number">2.3.2.</span> <span class="nav-text">PHP安装</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#mysql安装"><span class="nav-number">2.3.3.</span> <span class="nav-text">mysql安装</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#zabbix安装"><span class="nav-number">2.3.4.</span> <span class="nav-text">zabbix安装</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#zabbix4-2编译安装"><span class="nav-number">2.3.4.1.</span> <span class="nav-text">zabbix4.2编译安装</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#创建数据库导入数据"><span class="nav-number">2.3.4.2.</span> <span class="nav-text">创建数据库导入数据</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#修改php参数"><span class="nav-number">2.3.4.3.</span> <span class="nav-text">修改php参数</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#拷贝php文件到web目录"><span class="nav-number">2.3.4.4.</span> <span class="nav-text">拷贝php文件到web目录</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#修改zabbix-server配置文件"><span class="nav-number">2.3.4.5.</span> <span class="nav-text">修改zabbix_server配置文件</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#zabbix服务自启动"><span class="nav-number">2.3.4.6.</span> <span class="nav-text">zabbix服务自启动</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#启动zabbix-server"><span class="nav-number">2.3.4.7.</span> <span class="nav-text">启动zabbix_server</span></a></li></ol></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ElasticSearch-安装配置"><span class="nav-number">2.4.</span> <span class="nav-text">ElasticSearch 安装配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#jdk-安装配置配置"><span class="nav-number">2.4.1.</span> <span class="nav-text">jdk 安装配置配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#系统参数调整"><span class="nav-number">2.4.2.</span> <span class="nav-text">系统参数调整</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#elasticsearch-6-1-4-安装配置"><span class="nav-number">2.4.3.</span> <span class="nav-text">elasticsearch 6.1.4 安装配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#elasticsearch-head插件安装"><span class="nav-number">2.4.4.</span> <span class="nav-text">elasticsearch-head插件安装</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Kibana-安装配置"><span class="nav-number">2.5.</span> <span class="nav-text">Kibana 安装配置</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Kibana下载"><span class="nav-number">2.5.1.</span> <span class="nav-text">Kibana下载</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Kibana-安装配置-1"><span class="nav-number">2.5.2.</span> <span class="nav-text">Kibana 安装配置</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Zabbix-同-ElasticSearch对接"><span class="nav-number">2.6.</span> <span class="nav-text">Zabbix 同 ElasticSearch对接</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#zabbix-server配置"><span class="nav-number">2.6.1.</span> <span class="nav-text">zabbix_server配置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#添加Elasticsearch-mapping"><span class="nav-number">2.6.2.</span> <span class="nav-text">添加Elasticsearch mapping</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#1-添加uint-mapping"><span class="nav-number">2.6.2.0.1.</span> <span class="nav-text">1.添加uint_mapping</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#2-添加dbl-mapping"><span class="nav-number">2.6.2.0.2.</span> <span class="nav-text">2.添加dbl_mapping</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#3-添加str-mapping"><span class="nav-number">2.6.2.0.3.</span> <span class="nav-text">3.添加str_mapping</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#4-添加text-mapping"><span class="nav-number">2.6.2.0.4.</span> <span class="nav-text">4.添加text_mapping</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#5-添加log-mapping"><span class="nav-number">2.6.2.0.5.</span> <span class="nav-text">5.添加log_mapping</span></a></li></ol></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Kibana关联elasticsearch"><span class="nav-number">2.6.3.</span> <span class="nav-text">Kibana关联elasticsearch</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#创建索引正则"><span class="nav-number">2.6.3.1.</span> <span class="nav-text">创建索引正则</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#kibana过滤数据"><span class="nav-number">2.6.3.2.</span> <span class="nav-text">kibana过滤数据</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#附录：X-pack安装"><span class="nav-number">2.6.4.</span> <span class="nav-text">附录：X-pack安装</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#x-pack-安装"><span class="nav-number">2.6.4.1.</span> <span class="nav-text">x-pack 安装</span></a></li></ol></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">已经被时间上锁</span>

  
</div>

<div class="powered-by" style="color:white">
<i class="fa fa-user-md"></i><span id="busuanzi_container_site_uv">
  感谢您的来访<span>&nbsp|&nbsp Hosted by <a href="https://pages.coding.me" style="color:white;font-weight: bold ">Coding Pages</a>
</span>
</div>


        







        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.3"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.3"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.3"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.3"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.3"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.3"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: true,
        appId: 'HOjFznvmjBUW3uPdcns45OAT-gzGzoHsz',
        appKey: 'h0giMg2il1nwP5N0bGivit14',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  



</body>
</html>
<script type="text/javascript" src="/js/src/love.js"></script>
